Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

이미지 업로드 수정 #721

Merged
merged 3 commits into from
Oct 19, 2023
Merged

이미지 업로드 수정 #721

merged 3 commits into from
Oct 19, 2023

Conversation

hgo641
Copy link
Collaborator

@hgo641 hgo641 commented Oct 18, 2023

📄 Summary

close #716

굉장히 귀여운 PR 등장~ 코드 +5줄~
기존에 아이템 이미지들을 S3에 업로드하다가 예외가 발생하면, 예외가 발생하기 전에 업로드된 이미지들은 S3에 그대로 남아있었습니다.
S3 업로드시 예외가 발생하면 S3ImageEvent를 발행해, 요청으로 온 모든 이미지들을 S3에서 삭제하게 했습니다. (요청으로 온 이미지들중 업로드가 된 이미지들만 특정해서 지울 수도 있지만, 아이템당 최대 5개의 이미지만 가지기에 그냥 전부 삭제하게 했습니다. S3에 존재하지 않는 이미지를 삭제하는 요청이 간다면 무시되기에 괜찮다고 생각했음)

원래 하려고 했던 것...

S3 이미지 삭제를 @Async를 사용해 비동기로 처리하고 있습니다. @Async만 붙이면 요청 수만큼 thread를 생성하는 SimpleAsyncTaskExecutor를 쓰는 줄 알고 thread pool size 지정해주려고 했는데, 스프링부트에서는 @Async 만 해도 ThreadPoolTaskExecutor를 잘 가져오네요!!!ㅎㅎ (디폴트값인 core pool size 8 적용중)

core pool size라도 튜닝할까 했는데, 몇으로 해야할 지 잘 모르겠어요 ㅎㅎ 😥 어떤 걸 기준으로 잡고 thread를 설정해야 할지...............ㅎㅎ 의견이 있으시다면 코멘트로 남겨주십시오

  • 20KB * 100개의 이미지를 삭제할 때 350ms정도 소요 (데이터 더 추가해보겠)
  • 이미지 삭제시 최악의 경우 6101번의 삭제 필요
  • 여행하나당 평균 이미지 개수 5-6개정도(현재 데이터가 너무 적긴합니다 ㅋㅋ ㅠㅠ)

🙋🏻 More

@github-actions
Copy link

github-actions bot commented Oct 18, 2023

📝 Jacoco Test Coverage

Total Project Coverage 79.72%
File Coverage [39.39%]
ImageService.java 39.39%

Copy link
Collaborator

@LJW25 LJW25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

홍 고 생 하셨습니다 🍊

@hgo641 hgo641 merged commit d055516 into develop Oct 19, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

이미지 업로드 실패로 인한 이미지 삭제시 비동기 처리
3 participants